<template>
	<view class="mainView">
		<view class="content"><textarea class="content-text" placeholder="请输入您的意见或建议!" @input="input"></textarea></view>
		<view class="mini-btn"><button   size="mini" @click="submit">提交</button></view>
	</view>
</template>

<script>
	import unils from "../../unils/utils.js"
	export default {
		data() {
			return {
				'textValue':'',
			}
		},
		methods: {
			input:function(e){
				this.textValue = e.detail.value;
			},
			submit:function(){
				if(unils.stringIsEmpty(this.openid)){
					uni.showToast({
						title:"请先授权才能使用哦！",
						duration:2000,
						icon:'none',
					})
					return;
				}
				let that = this;
				let nickName = uni.getStorageSync('nickName');
				uni.request({
					url: that.websiteUrl+'/feedback',
					method:'POST',
					header: {
					        'x-requested-with': 'xmlhttprequest' //自定义请求头信息
					    },
					data:{
						'openid':that.openid,
						'nickname':nickName,
						'content':that.textValue
					},
					success:(res)=>{
						if(res.data.code != 1){
							uni.showToast({
								title:res.data.msg,
								duration:2000,
								icon:'none',
							})
						} else {
							uni.switchTab({
								url:"./my"
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.mainView{
	margin-top: 30px;
	// background-color: $uni-scroll-bg-clolr;
	.content{
		// margin: 10px;
		// background-color: #007AFF;
		margin: 10px;
		.content-text{
			width:100%;
			// background-color: #999999;
			width:96%;
			padding:18rpx 2%;
			line-height:1.6;
			font-size:28rpx;
			height:150rpx;
			border: 1px $uni-primary-color solid;
			border-radius: 5px;
		}
	}
	
	.mini-btn {
		display: flex;
		justify-content: center;
		align-items: center;
		button{
			background-color: $uni-primary-color;
			color:$uni-bg-color;
		}
	}
}
</style>
